<%@ page contentType="text/html; charset=utf-8" %>
<%@ include file="../common.jsp" %>
<jsp:include page="safe.jsp"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
              <link href="../CSS/style.css" rel="stylesheet">
    </head>
    <body>
        
        <%
            request.setCharacterEncoding("utf-8");
            if (request.getParameter("ISBN") != "") {
                String ISBN = request.getParameter("ISBN");
                String bookname = request.getParameter("bookname");
                String writer = request.getParameter("writer");
               String type =request.getParameter("type");
                String TPI = request.getParameter("TPI");
                int pDate = Integer.parseInt(request.getParameter("pDate"));
                String cover = request.getParameter("cover");
                float price = Float.valueOf(request.getParameter("price")).floatValue();
                String introduce = request.getParameter("introduce");
                if(introduce.equals("")) {
                    introduce = "暂无";
                }
                BookDetails book = new BookDetails();
              Booktype bt=new Booktype(type);
         
                book.setBookid(ISBN);
                book.setCover(cover);
                book.setBtid(bt.getBooktypeid());
                book.setDescription(introduce);
                book.setPrice(price);
                book.setYear(pDate);
                book.setName(writer);
                book.setTitle(bookname);
               // book.setPubilsher(TPI);         
                int ret=bookDB.save(book);
                if (ret==0){
              out.println("<script language='javascript'>alert('图书信息添加成功！');window.location.href='index.jsp';</script>");                                     
                } else {
                    out.println("<script language='javascript'>alert('图书信息添加失败！');window.location.href='book_add.jsp';</script>");
                }
            }

        %>
    </body>
</html>
